home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software Vault: The Games Collection 1
/
software vault.zip
/
software vault
/
CDR02
/
DCG303.ZIP
/
NEWGAME.ZIP
/
OBJECT.SCR
< prev
next >
Wrap
Text File
|
1993-06-27
|
41KB
|
1,223 lines
!
! Default script OBJECT.SCR.
!
! This is the default script for handling objects. It is invoked whenever
! an object is manipulated (Talk, Get, Drop, Wear, Remove, Look, Examine,
! Invoke, Use and Exit) under the following conditions:
!
! a) If the object has a script assigned to it, that script is invoked
! first.
! b) If the object's script terminates with CONTINUE, or if the object
! does not have a script, then this script is invoked.
!
! You may modify this script at will, but one thing to remember is that
! this script should NEVER terminate with CONTINUE. The reason is that
! objects may explicitly state that their script is 'OBJECT', in which
! case a 'CONTINUE' would execute this script twice! (Once as the script
! assigned to the object, and another time because the script ended with
! continue).
!
! (c) DC Software, 1992
!
!------------------------------------------------------------------------!
:@TALK ! Talk to the object or npc !
!------------------------------------------------------------------------!
! This script is called whenever the object or NPC you tried to talk
! to does not have it's own script for handling talking. Thus, it just
! prints a standard message. Since nothing really happens here, we
! omit the check to see if the player is alive.
! gosub STILLKICKING; - don't check !
if npc.count then
writeln( "The ", npc.type, " has nothing to say.." );
else
writeln( "How do you talk to an ", object.type, "?" );
endif;
STOP;
!------------------------------------------------------------------------!
:@GET ! Get the object (pick it up) !
!------------------------------------------------------------------------!
if npc.count then writeln( "You can't do that.." ); STOP; endif;
if object.endgame = END_ON_GET then ! Game ends on a GET of this object !
if object.endtext > 0 then ! .. this text is displayed first.. !
readtext( object.endtext );
endif; ! .. then the game ends. !
ENDGAME;
endif;
if object.type = CHEST and object.locktype then ! Locked !
writeln( "You must first UNLOCK the chest, then GET the gold!" );
elsif object.type = CHEST or object.type = GOLDSACK then
if object.value = 0 then
L(1) = object.count * player.hp * 10 + random( 100 ) + 1;
else
L(1) = object.value * object.count;
if L(1) <= 0 then
L(1) = object.value;
endif;
endif;
writeln( "Got ", $L1, " (gold pieces)." );
group.gold = group.gold + L(1);
vanish( object );
elsif object.type = FOOD and object.class = 0 then
writeln( "Got ", object.count, " units of food." );
group.food = group.food + object.count;
vanish( object );
elsif object.weight = 999 then
writeln( "The ", object.name, " is much too heavy." );
elsif object.weight = 998 then
writeln( "The ", object.name, " is can't be moved." );
elsif object.weight = 997 then
writeln( "Why would you want to take the ", object.name, "?" );
elsif object.weight > 255 then
writeln( "You can't move it!" );
elsif object.weight > player.mload then
writeln( "You are not strong enough to carry it!" );
elsif object.weight > 1 and object.weight + player.load > player.mload then
writeln( "Your load is too heavy!" );
else
L(0) = object.count;
move( object, player.bp ); ! OBJECT does not exist after MOVE !
if success then
writeln("Got ", L(0), " ", player.bp.name );
elsif object.count = L(0) then
writeln("You couldn't carry it");
else
writeln("You could only carry ", L(0) - object.count, " of them." );
endif;
endif;
STOP;
!------------------------------------------------------------------------!
:@DROP ! Drop the object on the floor !
!------------------------------------------------------------------------!
if curritem.count > 1 then
L(0) = getnum( "How many? ", 0, curritem.count );
if L(0) > 0 then
writeln( "You drop ", L(0), " ", curritem.name, "(s)" );
drop( curritem, L(0) );
endif;
else
writeln( "You drop the ", curritem.name );
drop( curritem );
endif;
STOP;
!------------------------------------------------------------------------!
:@WEAR ! Wear or Wield the object !
!------------------------------------------------------------------------!
L(0) = 0; ! Hands needed to hold the item..
on curritem.type goto
WR_FOOD, WR_WEAPON, WR_AMMO, WR_ARMOR, WR_SHIELD,
WR_AMULET, WR_RING, WR_POTION, WR_SCROLL, WR_STAFF;
!
! the rest can't be worn, so no need to list them..
! WR_CHEST, WR_KEYS, WR_GEMS, WR_BOOK, WR_GOLDSACK,
! WR_TORCH, WR_LANTERN, WR_ROPE, WR_HOOKS, WR_MIRROR,
! WR_SIGN, WR_VEHICLE
!
:WR_FOOD
:WR_AMMO
:WR_POTION
:WR_SCROLL
writeln( "How do you wear a ", curritem.type, "? " );
STOP;
:WR_WEAPON
gosub STILLKICKING;
if (player.class = ELF or player.class = WIZARD or player.class = ARCHER)
and curritem.weight > 5 + adjustments(player.str) then
writeln( "This weapon is too heavy for this character class." );
elsif player.class = WIZARD and curritem.hands > 1 then
writeln( "Wizards can only use one-handed weapons" );
elsif (player.class = WIZARD or player.class = DWARF) and curritem.class = MISSILE then
writeln( "Wizards and dwarfs can't use non-magical missile weapons" );
elsif player.weapon.count > 0 then
writeln( "You must first remove the ", player.weapon.name );
else
L(0) = curritem.hands; ! Hands needed to hold the weapon !
S0 = "wielding";
goto WR_DOIT;
endif;
STOP;
:WR_ARMOR
gosub STILLKICKING;
if (player.class = ELF or player.class = WIZARD) and
curritem.weight > 5 + adjustments(player.str) then
writeln( "This armor is too heavy for an elf or a wizard" );
elsif player.class = ARCHER and
curritem.weight > 10 + adjustments(player.str) then
writeln( "This armor is too cumbersome for an archer" );
elsif player.armor.count > 0 then
writeln( "You must first remove the ", player.armor.name );
else
S0 = "wearing";
goto WR_DOIT;
endif;
STOP;
:WR_SHIELD
gosub STILLKICKING;
if player.class = WIZARD or player.class = ARCHER or player.class = DWARF then
writeln( player.class, "s cannot use a shield!" );
elsif player.class = ELF and curritem.weight > 5 + adjustments(player.str) then
writeln( "The shield is too heavy for an ELF." );
elsif player.shield.count > 0 then
writeln( "You must first remove the ", player.shield.name );
else
L(0) = 1; ! A shield always needs 1 hand.. !
S0 = "using";
goto WR_DOIT;
endif;
STOP;
:WR_STAFF
gosub STILLKICKING;
L(0) = 1; ! A staff always needs 1 hand.. !
if player.class = FIGHTER then
writeln( "Fighters can't use magic staffs." );
elsif curritem.charges = 0 then
writeln( "The staff has no charges left.." );
elsif player.staff.count > 0 then
writeln( "You must first remove the ", player.staff.name );
else
S0 = "holding";
goto WR_DOIT;
endif;
STOP;
:WR_AMULET
:WR_RING
if player.class = FIGHTER then
writeln( "Fighters can't use magic ", curritem.type, "s." );
elsif curritem.charges = 0 then
writeln( "The ", curritem.type, " has no charges left.." );
elsif curritem.type = AMULET and player.amulet.count > 0 then
writeln( "You must first remove the ", player.amulet.name );
elsif curritem.type = RING and player.ring.count > 0 then
writeln( "You must first remove the ", player.ring.name );
else
S0 = "wearing";
goto WR_DOIT;
endif;
STOP;
:WR_DOIT
L(1) = 2; ! Player has 2 hands.. !
if player.weapon.count then dec( L(1), player.weapon.hands ); endif;
if player.shield.count then dec( L(1), 1 ); endif;
if player.staff.count then dec( L(1), 1 ); endif;
if L(0) > L(1) then
writeln( "You don't have enough free hands!" );
STOP;
endif;
!
move( curritem, player.body, 1 );
if success then
writeln( "You are now ", s0, " the ", player.body.name );
if player.body.type = ARMOR or player.body.type = SHIELD then
if player.armor.cursed or player.shield.cursed then
player.ac = 0;
else
inc(player.ac,player.body.ac);
endif;
elsif player.body.type = RING or player.body.type = AMULET then
if( player.body.charges > 0 ) then
curritem = player.body;
gosub M1_INVOKE;
if curritem.charges < 255 then
dec( curritem.charges );
endif;
else
writeln( "The ", player.body.type, " has no charges." );
endif;
endif;
endif;
STOP;
!------------------------------------------------------------------------!
:@REMOVE ! Remove an object !
!------------------------------------------------------------------------!
if curritem.cursed then
writeln( "The ", curritem.type, " is cursed and cannot be removed.." );
STOP;
endif;
move( curritem, player.bp, 1 );
if success then
if player.hp = 0 then
writeln( "You remove the ", player.bp.name, " from the body of ", player.name );
else
writeln( player.name, " removes the ", player.bp.name );
endif;
endif;
STOP;
!------------------------------------------------------------------------!
:@LOOK ! Look at an object !
!------------------------------------------------------------------------!
L(255) = FALSE; ! Do not give DETAILED description !
gosub DESCRIBE;
STOP;
!------------------------------------------------------------------------!
:@EXAMINE ! Examine the object in detail !
!------------------------------------------------------------------------!
L(255) = TRUE; ! Give DETAILED description !
gosub DESCRIBE;
STOP;
!------------------------------------------------------------------------!
:@INVOKE ! Invoke an object we are carrying..
!------------------------------------------------------------------------!
! Called to use an an object in the current player's backpack. The
! action varies depending on the type of object. For example, food
! is consumed, potions, amulets, scrolls, etc. have their magical
! effect invoked.
gosub STILLKICKING;
if curritem.endgame = END_ON_USE then
if curritem.endtext > 0 then ! .. this text is displayed first.. !
readtext( curritem.endtext );
endif; ! .. then the game ends. !
ENDGAME;
endif;
if curritem.type = FOOD or curritem.type = POTION then
player.energy = 255; ! Not hungry any more..
gosub M1_INVOKE;
if curritem.type = POTION and curritem.count > 1 then
curritem.name = curritem.class;
endif;
dec( curritem.count );
elsif curritem.type = SCROLL or curritem.type = STAFF then
gosub M2_INVOKE;
elsif curritem.type = GEMS or curritem.type = RING or curritem.type = AMULET then
gosub M1_INVOKE;
if curritem.charges < 255 then
dec( curritem.charges );
if curritem.count > 1 then
curritem.name = curritem.class;
endif;
if curritem.type = GEMS and curritem.charges = 0 then
writeln( "The ", curritem.type, " vanishes after you use it." );
dec( curritem.count );
endif;
endif;
else
writeln( "The ", curritem.name, " has no magical properties.." );
endif;
STOP;
!------------------------------------------------------------------------!
:@USE ! Use an object laying on the ground before us..
!------------------------------------------------------------------------!
!
! Called when an object that is laying on the ground is 'used'. Note that
! 'use' means different things for different object types, and that in
! order to invoke an item you have 'get' it and sometimes 'wear' it.
!
if object.endgame = END_ON_USE then
if object.endtext > 0 then ! .. this text is displayed first.. !
readtext( object.endtext );
endif; ! .. then the game ends. !
ENDGAME;
endif;
on object.type goto
USE_FOOD, USE_WEAPON, USE_AMMO, USE_ARMOR, USE_SHIELD,
USE_AMULET, USE_RING, USE_POTION, USE_SCROLL, USE_STAFF,
USE_CHEST, USE_KEYS, USE_GEMS, USE_BOOK, USE_GOLDSACK,
USE_TORCH, USE_LANTERN, USE_ROPE, USE_HOOKS, USE_MIRROR,
USE_SIGN, USE_VEHICLE;
writeln( "I don't know how to do that with the ", object.name );
STOP;
:USE_FOOD
:USE_POTION
if object.class then
writeln( "You must 'get' it, then 'quaff' (eat) it.." );
else
writeln( "Just 'get' it.." );
endif;
STOP;
:USE_GEMS
:USE_SCROLL
writeln( "You must first 'get' it, then 'invoke' it.." );
STOP;
:USE_AMULET
:USE_RING
:USE_ARMOR
:USE_WEAPON
:USE_SHIELD
:USE_STAFF
writeln( "You must first 'get' it, then 'wear' or 'wield' it.." );
STOP;
:USE_AMMO
writeln( "Just carry it in your backpack. If you 'wield' a " );
writeln( "weapon that uses this type of ammo, it will get used" );
writeln( "automaticly." );
STOP;
:USE_CHEST
! Unlock the chest !
if object.locktype then
L(0) = 0;
:UCLOOP
setbp( player, L(0) );
if player.bp.type = KEYS and player.bp.keytype = object.locktype then
writeln( object.name, " unlocked.." );
object.locktype = 0;
STOP;
endif;
inc( L(0) );
if L(0) < 16 goto :UCLOOP;
writeln( "You don't have the right key! Break the lock?" );
if getstr( "Yes", "No" ) = 0 then
if random( 2 + adjustments(player.str) ) > 0 then
write( "You broke the lock!" );
if object.traptype = 1 then
voice( "Argh", 1000 ); ! 1000 = DCSOUNDS.VFL !
writeln( "Argh.. Poison trap!" );
player.poisoned = 1;
elsif object.traptype > 1 then
voice( "Explode", 1000 ); ! Play standard sound effect !
writeln( "Bomb Trap!" );
dec( player.hp, object.damage );
if player.hp = 0 then
writeln( player.name, " has died.." );
endif;
endif;
object.locktype = 0;
else
writeln( "It doesn't break!" );
endif;
else
writeln( "Ok." );
endif;
else
writeln( "It is not locked.." );
endif;
STOP;
:USE_KEYS
writeln( "Just 'Get' it and carry it in case you find a lock that" );
writeln( "the key can open!" );
STOP;
:USE_BOOK
writeln( "To read it, just 'Look' at it.." );
STOP;
:USE_GOLDSACK
L(1) = getnum("How many gold pieces do you want to put in it?",
0, group.gold / 10) * 10;
if L(1) then
writeln( "You put ", $L1, " in the bag." );
inc( object.value, L(1) );
dec( group.gold, L(1) );
else
writeln( "Smart move.." );
endif;
STOP;
:USE_TORCH
:USE_LANTERN
writeln( "Save your torches.. I haven't implemented LIGHT yet!" );
STOP;
:USE_ROPE
writeln( "After fooling around with it for a while, you manage to" );
writeln( "get yourself tangled up..." );
STOP;
:USE_HOOKS
voice( "Ouch", 1000 );
writeln( "Ouch! (it's sharp!)" );
STOP;
:USE_MIRROR
writeln( "Yes, you are ugly, but that doesn't matter here.." );
STOP;
:USE_SIGN
writeln( "It's not yours. You can 'Read' it if you wish.." );
STOP;
:USE_VEHICLE
if group.vehicle.count then
writeln( "You must first exit the one you are in!" );
STOP;
endif;
if object.x <> group.x and object.y <> group.y then
writeln( "You must be standing next to the ", object.name );
else
group.x = object.x; ! Move over to it !
group.y = object.y;
move( object, group.vehicle, 1 ); ! Now board the object !
if success then
writeln( "You are on riding the ", group.vehicle.name );
endif;
endif;
STOP;
!------------------------------------------------------------------------!
:@EXIT ! Exit a VEHICLE (since this is an object we are talking about..)
!------------------------------------------------------------------------!
if curritem.count = 0 then
writeln("You are already on foot!" );
STOP;
endif;
if curritem.type <> VEHICLE then
writeln("BUG: CURRITEM in :@EXIT in OBJECT.SCR is not a vehicle!" );
endif;
if group.vehicle.count = 0 then
writeln("BUG: CURRITEM is not GROUP.VEHICLE on @EXIT in OBJECT.SCR" );
endif;
drop( group.vehicle );
voice( "Exit", 1000 );
writeln( "You are now on foot.." );
STOP;
!------------------------------------------------------------------------!
:@ATTACK ! Attack an object or a person !
!------------------------------------------------------------------------!
if npc.count then
if npc.type = HOSTILE then
FIGHT;
!- Script ends when you 'FIGHT' -!
endif;
writeln( "Find some bad guys to fight!" );
STOP;
endif;
if object.type = CHEST then
if object.locktype then
writeln( "Instead of fighting it, try 'UNLOCK'!" );
else
writeln( "It's not even locked, why fight it?" );
endif;
else
writeln( "Why would you want to fight the ", object.name );
endif;
STOP;
!------------------------------------------------------------------------!
!-- SCRIPT SUBROUTINES ARE GROUPED HERE AT THE END. THIS IS A CHOICE --!
!-- NOT A REQUIREMENT. IT MAKES THE MAIN SCRIPT CODE ABOVE A LITTLE --!
!-- BIT EASIER TO FOLLOW. ---------------------------------------------!
!------------------------------------------------------------------------!
!------------------------------------------------------------------------!
! STILLKICKING: Subroutine to verify that the player is alive before !
! allowing him/her/it to perform an action. !
!------------------------------------------------------------------------!
:STILLKICKING
if player.hp = 0 then
writeln( player.name, " is dead!" );
STOP;
endif;
RETURN;
!------------------------------------------------------------------------!
!
! SUBROUTINE: DESCRIBE
!
! This routine is invoked from @LOOK, @EXAMINE and by the ANALYZE spell
! to describe a given item.
!
!------------------------------------------------------------------------!
:DESCRIBE
!------------------------------------------------------------------------!
! First, handle the case where you are looking at a CHARACTER
if npc.count then
if npc.picture >= 0 then
viewpcx( npc );
if success then
pause;
endif;
paint(window); ! Assumes the picture fits in the window !
endif;
write( "Name: ", npc.name, ", Type: ", npc.type );
if npc.type = HOSTILE and npc.weapon.count then
write( ", Weapon: ", npc.weapon.name, ", Damage: ", npc.weapon.damage, ", Range: ", npc.weapon.range );
endif;
if L(255) then
write( ", Class: ", npc.class, ", Lvl: ", npc.level, ", AC: ", npc.ac, ", HP: ", npc.hp );
endif;
writeln(".");
STOP;
endif;
if object.picture >= 0 then
viewpcx( object );
if success then
pause;
endif;
paint(window); ! Assumes the picture fits in the window !
elsif object.type = SIGN or object.type = BOOK then
readtext( object.text );
STOP;
endif;
write( "You see a ", object.name );
if NOT L(255) then
writeln;
STOP;
endif;
write( ", Type: ", object.type );
!
! The following is a 'cascading if..then..elsif..elsif.....else..endif'
! statement. It is used here to illustrate it's usefulness. The same
! code could have been written with a 'ON object.type GOTO' statement.
!
if object.type = FOOD or object.type = POTION then
if object.class then
write( ", Class: ", object.class );
if object.class <> CURE then
write( ", Units: ", object.units );
endif;
endif;
elsif object.type = WEAPON then
write( ", Class: ", object.class,
", Hands: ", object.hands,
", Range: ", object.range,
", Damage: ", object.damage );
if object.ammoneeded then
write( ", Needs ammo type: ", object.ammo_type );
endif;
elsif object.type = AMMO then
write( ", Ammo Type: ", object.ammotype );
if object.traptype then
write( ", Poisoned" );
endif;
if object.damage then
write( ", Extra Damage: ", object.damage );
endif;
elsif object.type = ARMOR or object.type = SHIELD then
write( ", Armor Class: ", object.ac );
if object.cursed then
write( " Cursed!" );
endif;
elsif object.type = AMULET or object.type = RING or object.type = GEMS then
if object.class then
write( ", Class: ", object.class );
write( ", Charges: ", object.charges );
if object.class <> CURE then
write( ", Units: ", object.units );
if object.permanent then
write( ", Permanent!" );
else
write( ", Temporary" );
endif;
endif;
if object.cursed then
write( ", Cursed!" );
endif;
endif;
elsif object.type = SCROLL then
write( ", Class: ", object.class );
elsif object.type = STAFF then
write( ", Class: ", object.class, ", Charges: ", object.charges );
elsif object.type = CHEST then
if object.locktype then
write( ", Locked!" );
if object.traptype = 0 then
write( ", no traps" );
elsif object.traptype = 1 then
write( ", poison trap" );
else
write( ", bomb damage: ", object.traptype );
endif;
endif;
! elsif object.type = KEYS then
! nothing special about it
! elsif object.type = BOOK then
! nothing special about it
! elsif object.type = GOLDSACK then
! nothing special about it
! elsif object.type = TORCH then
! nothing special about it
! elsif object.type = LANTERN then
! nothing special about it
! elsif object.type = ROPE then
! nothing special about it
! elsif object.type = HOOKS then
! nothing special about it
! elsif object.type = MIRROR then
! nothing special about it
! elsif object.type = SIGN then
! nothing special about it
elsif object.type = VEHICLE then
write( ", Class: ", object.class );
! else
! user defined type?
endif;
if object.weight > 1 and object.weight < 256 then
write( ", Weight: ", object.weight );
endif;
writeln( "." );
return;
!------------------------------------------------------------------------!
!
! SUBROUTINE: M1_INVOKE
!
! Type 1 Magic - Affects the person invoking the magic..
!
! This portion of the script is invoked whenever an individual in the
! adventurer's group:
!
! a) Eats food that has a magical effect
! b) Drinks a potion with a magical effect
! c) Successfully wears a ring or an amulet with a magical effect
! d) Uses a GEM that has a magical effect.
!
! When invoked, PLAYER is the person that will be affected, and CURRITEM
! is the item that has the magical effect, and which is either being
! worn or in the character's backpack. OBJECT and NPC are not defined.
!
!------------------------------------------------------------------------!
:M1_INVOKE
!------------------------------------------------------------------------!
if curritem.cursed and curritem.permanent then
curritem.permanent = FALSE;
writeln( "WARNING: This object was 'cursed' and had 'permanent' effect!" );
writeln( "WARNING: The effect has been made 'temporary' by OBJECT.SCR" );
endif;
on curritem.class goto
M1_NONE, M1_CURE, M1_HEAL, M1_POISON, M1_RESTORE,
M1_STR, M1_DEX, M1_SPD, M1_AIM, M1_AC,
M1_HP, M1_IQ, M1_PWR;
:M1_NONE
writeln( "Nothing happens.." );
return;
:M1_CURE
if player.poisoned then
player.poisoned = 0;
writeln( player.name, " is now cured." );
else
writeln( "Nothing happens.." );
endif;
return;
:M1_HEAL
if player.hp >= player.mhp then
writeln( "Nothing happens.." );
elsif player.hp = 0 then
writeln( player.name, " is beyond help.." );
else
if curritem.units > 0 then
L(0) = curritem.units; ! always heals the same points !
else
L(0) = random(player.mhp - player.hp)+1; ! heal a random number of points !
endif;
voice( "Tada", 1000 );
if player.hp + L(0) < player.mhp then
writeln( player.name, " heals ", L(0), " hit points.." );
inc( player.hp, L(0) );
else
writeln( player.name, " has been completely healed!" );
player.hp = player.mhp;
endif;
endif;
return;
:M1_POISON
if NOT player.poisoned then
player.poisoned = 1;
voice( "DudSpell", 1000 );
writeln( "You feel sick.." );
else
voice( "Boing", 1000 );
writeln( "You feel worse.." );
endif;
return;
:M1_RESTORE
if player.hp >= player.mhp then
writeln( "Nothing happens.." );
elsif player.hp = 0 then
writeln( player.name, " is beyond help.." );
else
voice( "OkSpell", 1000 );
player.hp = player.mhp;
writeln( player.name, " is completely healed!" );
endif;
return;
:M1_STR
if curritem.cursed then
player.str = 0;
voice( "DudSpell", 1000 );
writeln( "Something went wrong.." );
else
voice( "OkSpell", 1000 );
inc( player.str, curritem.units );
if curritem.permanent then
inc( player.mstr, curritem.units );
endif;
writeln( player.name, "'s strength increased by ", curritem.units, "!" );
endif;
return;
:M1_DEX
if curritem.cursed then
player.dex = 0;
voice( "DudSpell", 1000 );
writeln( "Something went wrong.." );
else
voice( "OkSpell", 1000 );
inc( player.dex, curritem.units );
if curritem.permanent then
inc( player.mdex, curritem.units );
endif;
writeln( player.name, "'s dexterity increased by ", curritem.units, "!" );
endif;
return;
:M1_SPD
if curritem.cursed then
player.spd = 0;
voice( "DudSpell", 1000 );
writeln( "Something went wrong.." );
else
voice( "OkSpell", 1000 );
inc( player.spd, curritem.units );
if curritem.permanent then
inc( player.mspd, curritem.units );
endif;
writeln( player.name, "'s speed increased by ", curritem.units, "!" );
endif;
return;
:M1_AIM
if curritem.cursed then
player.aim = 0;
voice( "DudSpell", 1000 );
writeln( "Something went wrong.." );
else
voice( "OkSpell", 1000 );
inc( player.aim, curritem.units );
if curritem.permanent then
inc( player.maim, curritem.units );
endif;
writeln( player.name, "'s aim increased by ", curritem.units, "!" );
endif;
return;
:M1_AC
if curritem.cursed then
player.ac = 0;
voice( "DudSpell", 1000 );
writeln( "Something went wrong.." );
else
voice( "OkSpell", 1000 );
inc( player.ac, curritem.units );
if curritem.permanent then
inc( player.mac, curritem.units );
endif;
writeln( player.name, "'s armor class increased by ", curritem.units, "!" );
endif;
return;
:M1_HP
if curritem.cursed then
player.hp = player.hp / 3 + 1;
writeln( player.name, " has been seriously injured!" );
else
voice( "OkSpell", 1000 );
inc( player.hp, curritem.units );
if curritem.permanent then
inc( player.mhp, curritem.units );
endif;
writeln( player.name, "'s hit points increased by ", curritem.units, "!" );
endif;
return;
:M1_IQ
if curritem.cursed then
player.iq = 0;
voice( "DudSpell", 1000 );
writeln( "Something went wrong.." );
else
voice( "OkSpell", 1000 );
inc( player.iq, curritem.units );
if curritem.permanent then
inc( player.miq, curritem.units );
endif;
writeln( player.name, "'s i.q. increased by ", curritem.units, "!" );
endif;
return;
:M1_PWR
if player.class = ELF or player.class = WIZARD then
if curritem.cursed then
player.pwr = 0;
voice( "DudSpell", 1000 );
writeln( "Something went wrong.." );
else
inc( player.pwr, curritem.units );
if curritem.permanent then
inc( player.mpwr, curritem.units );
endif;
voice( "OkSpell", 1000 );
writeln( player.name, "'s power increased by ", curritem.units, "!" );
endif;
else
voice( "Argh", 1000 );
write( player.name, " screams and falls to the ground, " );
if player.hp < 3 then
writeln( "dead!" );
player.hp = 0;
else
writeln( "holding his head.." );
dec( player.hp, 2 );
endif;
endif;
return;
!------------------------------------------------------------------------!
!
! SUBROUTINE: M2_INVOKE
!
! Type 2 Magic - Affects an object or a another person
!
! This portion of the script handles magic spells which affect objects
! or persons other than the caster. When invoked, the PLAYER is the
! person that invoked the spell and CURRITEM is the object that was used
! to invoke the spell (which is either being worn or carried by the
! player).
!
! The OBJECT and NPC are undefined. If the spell requires a target,
! the 'LOCATE' function can be used to select an object or character
! to cast the spell on. The locate function returns the distance in blocks
! to the selected target. If none is selected, the value is -1, and FAILURE
! is set.
!
! After a LOCATE, either OBJECT or NPC will be set depending on whether the
! user selected an object or a character (or monster, during a fight).
!
! To figure out which one was selected, check if NPC.COUNT is greater than
! 0. If it is, a character was selected. If it is not, then an object was
! selected.
!
!------------------------------------------------------------------------!
:M2_INVOKE
!------------------------------------------------------------------------!
if curritem.class = NONE then
writeln( "Nothing happens.." );
return;
endif;
if curritem.count = 0 then
writeln( "Oops, no object in OBJECT.SCR, m2 invoke" );
stop;
endif;
if curritem.class = DAMAGE or curritem.class = CONFUSE or
curritem.class = SCARE or curritem.class = PARALYZE or
curritem.class = KILL then
if not fighting then
writeln( "This spell can only be used during a fight.." );
return;
endif;
!
! L(5) will contain the TOTAL experience points gained when done..
! L(6) is the maximum damage that will be done to a single monster..
! L(8) is the maximum total damage that can be done to a group of monsters..
! L(9) is the TOTAL number of monsters affected AFTER the spell
!
L(5) = 0;
L(6) = player.level + adjustments(player.pwr) / 2 + 1;
if L(6) <= 0 then
writeln( "The spell failed.." );
STOP;
endif;
if curritem.units then
L(8) = curritem.units;
else
L(8) = player.iq + adjustments(player.iq);
endif;
L(9) = 0;
endif;
if curritem.type = STAFF and curritem.charges = 0 then
writeln( "The ", curritem.name, " doesn't work.." );
return;
endif;
if curritem.class <> LEAVE and
curritem.class <> ZOOM and
curritem.class <> INFORM and
curritem.class <> DOORS and
curritem.class <> RESURRECT then
write( curritem.class, " what:" );
L(1) = locate; ! SETS THE TARGET FOR THE SPELL !
if L(1) = 0 then
writeln( "nothing.." );
return;
endif;
! Either NPC.COUNT or OBJECT.COUNT identifies selected object/char !
if npc.count then ! It's a character, not an object..
if npc.type = HOSTILE then
writeln( npc.name ); ! monster's don't have classes.. !
else
writeln( npc.class ); ! Human, elf, dwarf, etc.. !
endif;
if curritem.class = DESTROY or curritem.class = DUPLICATE or
curritem.class = RECHARGE or curritem.class = FLOAT then
writeln( "This spell only work's on objects!" );
goto M2_EXIT;
endif;
else
writeln( object.type ); ! Food, weapon, ring, etc.. !
endif;
endif;
on curritem.class goto
M2_EXIT, M2_DESTROY, M2_DUPLICATE, M2_LEAVE,
M2_RESURRECT,M2_INFORM, M2_LOCATE, M2_KILL,
M2_CONFUSE, M2_SCARE, M2_DAMAGE, M2_PARALYZE,
M2_RECHARGE, M2_FLOAT, M2_ANALYZE, M2_ZOOM;
:M2_NONE ! No magic..
writeln( "Nothing happens.." );
goto M2_EXIT;
:M2_DESTROY ! Destroy an object pwr = 5, rng=10
! if player.pwr < 5 goto M2_NOPOWER; ! No power check needed
if L(1) > 10 goto M2_OUTOFRANGE;
voice( "Explode", 1000 );
writeln( "The ", object.type, " is destroyed.." );
vanish( object );
L(4) = 5;
goto M2_EXIT;
:M2_DUPLICATE ! Duplicates an object pwr = 40, rng=1
! if player.pwr < 40 goto M2_NOPOWER; ! No power check needed
if L(1) > 1 goto M2_OUTOFRANGE;
inc( object.count, 1 ); ! Creates an identical copy !
L(4) = 40;
goto M2_EXIT;
:M2_LEAVE ! Exit through the 'exit' door from anywhere...
if world.type <> DUNGEON then
voice( "Boing", 1000 );
writeln( "This spell only work's in dungeons.." );
return;
endif;
! if player.pwr < 5 goto M2_NOPOWER; ! No power check needed
enter( world.edgedoor );
voice( "OkSpell", 1000 );
writeln( "You leave this level of the dungeon.." );
L(4) = 5;
goto M2_EXIT;
:M2_RESURRECT ! Revive a DEAD person pwr = 50, rng=1
! if player.pwr < 50 goto M2_NOPOWER; ! No power check needed
if L(1) > 1 goto M2_OUTOFRANGE;
write( "Resurrect: " );
L(0) = select( group );
if player.hp > 0 then
voice( "Boing", 1000 );
writeln( "This player is NOT dead!" );
return;
endif;
voice( "OkSpell", 1000 );
writeln( player.name );
player.hp = 2;
writeln( player.name, " is alive, but weak.." );
L(4) = 50;
goto M2_EXIT;
:M2_INFORM ! Displays some text pwr = 5
! if player.pwr < 5 goto M2_NOPOWER; ! No power check needed
if L(1) > 5 goto M2_OUTOFRANGE;
loadhint;
writeln( "The wind seems to carry a random phrase to your ears.." );
writeln( s0 );
L(4) = 5;
goto M2_EXIT;
:M2_LOCATE ! Locate doors pwr = 10
! if player.pwr < 10 goto M2_NOPOWER; ! No power check needed
if L(1) > 10 goto M2_OUTOFRANGE;
L(0) = 0;
:LDLOOP
if world.doorx(L0) > 0 and world.doory(L0) > 0 then
frame( world.doorx(L0), world.doory(L0), SYS_FRAME );
endif;
inc(L0);
if L(0) < 16 goto LDLOOP;
L(4) = 10;
goto M2_EXIT;
:M2_KILL ! Kill 1 enemy during battle pwr = 20, rng=6
writeln( npc.name, " killed. +", npc.hp, " exp." );
inc( player.exp, npc.hp );
npc.hp = 0;
STOP;
:M2_DAMAGE ! Causes damage to monsters pwr = 5, rng=12
S0 = "hit";
foreach npc do
L(7) = min( npc.hp, random(L6) ); ! How much damage to this one monster?
if L(7) > 0 then
frame(npc.x, npc.y, SYS_SPLAT); wait(1); frame(npc.x, npc.y, SYS_SPLAT);
write( npc.name );
if L(7) < npc.hp then
write( " hit." );
dec( npc.hp, L(7) ); ! Hit the monster..
else
write( " killed!" );
npc.hp = 0;
endif;
writeln( " +", L(7), " exp." );
inc(L9); ! Count of affected npcs
inc( L(5), L(7) ); ! Accumulate experience..
if L(5) > L(8) goto DCSPEXIT; ! Stop when total of L(8) points used
endif;
endfor;
goto DCSPEXIT;
:M2_CONFUSE ! Makes monsters shoot at other monsters pwr = 1, rng=12
S0 = "confused";
foreach npc do
L(7) = min( npc.hp, random(L6) ); ! How much confusion to this one monster?
if L(7) > 0 and npc.confused = 0 then
frame(npc.x, npc.y, SYS_SPLAT); wait(1); frame(npc.x, npc.y, SYS_SPLAT);
inc(L9); ! Count of affected npcs
npc.confused = L(7); ! Confuse for 'n' units
inc( L(5), L(7) ); ! Accumulate experience..
if L(5) > L(8) goto DCSPEXIT; ! Stop when total of L(8) points used
endif;
endfor;
goto DCSPEXIT;
:M2_SCARE ! Scares monsters pwr = 2, rng=12
S0 = "scared";
foreach npc do
L(7) = min( npc.hp, random(L6) ); ! How much 'fright' to this one monster?
if L(7) > 0 and npc.scared = 0 then
frame(npc.x, npc.y, SYS_SPLAT); wait(1); frame(npc.x, npc.y, SYS_SPLAT);
inc(L9);
npc.scared = L(7); ! Frighten for 'n' units
inc( L(5), L(7) ); ! Accumulate experience..
if L(5) > L(8) goto DCSPEXIT; ! Stop when total of L(8) points used
endif;
endfor;
goto DCSPEXIT;
:M2_PARALYZE ! Monster can't move pwr = 5, rng=12
S0 = "paralyzed";
foreach npc do
L(7) = min( npc.hp, random(L6) ); ! How much paralysis to this one monster?
if L(7) > 0 and npc.paralyzed = 0 then
frame(npc.x, npc.y, SYS_SPLAT); wait(1); frame(npc.x, npc.y, SYS_SPLAT);
inc(L9);
npc.paralyzed = L(7); ! Paralyze for 'n' units
inc( L(5), L(7) ); ! Accumulate experience..
if L(5) > L(8) goto DCSPEXIT; ! Stop when total of L(8) points used
endif;
endfor;
goto DCSPEXIT;
:M2_RECHARGE ! Recharge an ITEM pwr = 25, rng=1
! if player.pwr < 25 goto M2_NOPOWER; ! No power check needed
if L(1) > 1 goto M2_OUTOFRANGE;
if object.type = RING or object.type = AMULET or object.type = STAFF then
inc( object.charges, random(player.level)+1 );
voice( "OkSpell", 1000 );
writeln( "The ", object.type, " now has ", object.charges, " charges." );
else
voice( "Boing", 1000 );
writeln( "The smell of rotten eggs fills the air.." );
endif;
L(4) = 25;
goto M2_EXIT;
:M2_FLOAT ! Remove an object's weight pwr = 10, rng=1
! if player.pwr < 10 goto M2_NOPOWER; ! No power check needed
if L(1) > 1 goto M2_OUTOFRANGE;
if object.weight < 255 then
object.weight = object.weight / 2 + 1;
voice( "OkSpell", 1000 );
writeln( "The ", object.type, " is now much lighter.." );
else
voice( "Boing", 1000 );
writeln( "It's didn't work. The ", object.type, " is too heavy." );
endif;
L(4) = 10;
goto M2_EXIT;
:M2_ANALYZE ! Discover object's properties pwr = 10, rng=1
! if player.pwr < 10 goto M2_NOPOWER; ! No power check needed
if L(1) > 1 goto M2_OUTOFRANGE;
L(255) = TRUE; ! Give DETAILED description !
gosub DESCRIBE;
L(4) = 10;
goto M2_EXIT;
:M2_ZOOM ! View the world..
! if player.pwr < 25 goto M2_NOPOWER; ! No power check needed
viewpcx( world );
if success then
pause;
endif;
paint( screen ); ! If you don't have any WORLD###.PCX files, you can use !
! paint( WINDOW ) instead of paint( SCREEN) !
L(4) = 25;
goto M2_EXIT;
:M2_NOPOWER
writeln( "You don't have enough power!" );
return;
:M2_OUTOFRANGE
writeln( "You are too far away from the ", object.name );
return;
:DCSPEXIT
if L(9) then
write( L(9), " foes were ", S0 );
if L(5) then
writeln( " for a total of +", L(5), " experience!" );
inc( player.exp, L(5) ); ! Grant experience..
else
writeln( " With no effect" );
endif;
else
writeln( "No effect.." );
endif;
goto M2_EXIT;
:M2_EXIT
if curritem.count > 0 then
if curritem.count > 1 then
curritem.name = curritem.class;
endif;
if curritem.type = SCROLL then
dec( curritem.count ); ! Item disapears if count reaches 0 !
elsif curritem.type = STAFF then
dec( curritem.charges ); ! One less !
endif;
else
dec( player.pwr, L(4) ); ! A spell !
endif;
return;